﻿using BussinessObject.ObjectTwo;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ProjectHK3.App_Code;
using DataAccess.ObjectTwo;

namespace ProjectHK3.Object_One
{
    public partial class News1 : System.Web.UI.Page
    {
        B_LoadGidAD ex = new B_LoadGidAD();
        DataTable tb = new DataTable();
        B_Delete zx = new B_Delete();
        D_GetAccount dg = new D_GetAccount();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
               
                load();
            }
            
        }
        public void load()
        {
            tb = ex.loadNew();
            Label4.Text = tb.Rows.Count.ToString();
            GridView1.DataSource = tb;
            GridView1.DataBind();
        }

        protected void _lbtDeleteFeedBack_Command(object sender, CommandEventArgs e)
        {
            if (e.CommandName == "delete")
            {
                Session["New"] = Convert.ToInt32(e.CommandArgument.ToString());

            }
        }

        protected void _lbtDetailsFee_Command(object sender, CommandEventArgs e)
        {
            Session["New"] = Convert.ToInt32(e.CommandArgument.ToString());
            Response.Redirect("../Object One/NewsDetail.aspx");

        }

        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int tam = Convert.ToInt32(Session["New"].ToString());
            if (zx.DeleteNew(tam) == true)
            {

                Alert.Show("Delete Successful.");
                load();
            }
            else
            {
                Alert.Show("Delete fail!!!");
            }
        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            tb = dg.SearchNews(TextBox1.Text);
            GridView1.DataSource = tb;
            GridView1.DataBind();
            Label4.Text = tb.Rows.Count.ToString();
        }
    }
}